#!/usr/bin/env python3
"""
核验记录Pydantic模式
"""

from datetime import datetime

from pydantic import BaseModel, Field


class VerificationRecordBase(BaseModel):
    """核验记录基础模型"""
    visitor_id: int | None = Field(None, description="关联访客ID")
    visitor_name: str = Field(..., description="访客姓名")
    visitor_phone: str | None = Field(None, description="访客电话")
    visitor_type: str = Field("regular", description="访客类型")
    special_visitor_flag: bool = Field(False, description="特殊访客标志")
    qr_code_content: str | None = Field(None, description="二维码内容")
    verify_time: datetime = Field(default_factory=datetime.now, description="核验时间")
    verify_result: str = Field("pending", description="核验结果")
    rejection_reason: str | None = Field(None, description="拒绝原因")
    guard_id: int = Field(..., description="核验的门卫ID")
    guard_name: str = Field(..., description="核验的门卫姓名")
    guard_point: str = Field(..., description="核验点")
    related_audit_log_id: int | None = Field(None, description="关联的审计日志ID")


class VerificationRecordCreate(VerificationRecordBase):
    """创建核验记录模型"""
    pass


class VerificationRecordUpdate(VerificationRecordBase):
    """更新核验记录模型"""
    pass


class VerificationRecord(VerificationRecordBase):
    """核验记录响应模型"""
    id: int = Field(..., description="主键ID")
    created_at: datetime = Field(..., description="创建时间")

    class Config:
        from_attributes = True


class VerificationRecordListResponse(BaseModel):
    """核验记录列表响应模型"""
    records: list[VerificationRecord] = Field(..., description="核验记录列表")
    total: int = Field(..., description="总数")
    skip: int = Field(..., description="跳过数量")
    limit: int = Field(..., description="限制数量")